home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 May: Tool Chest / Apple_Developer_CD_Series_May_1994_Tool_Chest.iso / Sample Code / Pascal Sample 3.0B10 / Source / Sample.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-13  |  6.3 KB  |  153 lines  |  [TEXT/MPS ]

  1. /******************************************************************************
  2. *
  3. * Sample.h -- constants for the Sample code and resources
  4. *
  5. * Developer Support Center
  6. * Apple Computer, Inc.
  7. * Copyright 1988-1993, Apple Computer, Inc.  All rights reserved.
  8. *
  9. * This FILE contains constant definitions for the Sample code, including
  10. * dialog IDs, resource IDs and the like.
  11. *
  12. ******************************************************************************/
  13.  
  14. /*    These #defines correspond to values defined in the Pascal source code.
  15.     Sample.c and Sample.r include this FILE. */
  16.  
  17. /*    The minimum partition an application requests from the system depends
  18.     on many things.  What kind of work does this application do?  What
  19.     environment do you think is reasonable for users of the application?
  20.     what is “reasonable functionality?”  What about performance?  And so
  21.     on. Here are some things to consider when determining the minimum
  22.     size (and preferred size) for your application. This list is pretty
  23.     much in order of importance, but by no means complete. 
  24.  
  25.     1.    What is the minimum size needed to give almost 100 percent
  26.         assurance that the application won't crash because it ran out of
  27.         memory? This includes not only things that you do have direct control
  28.         over such as checking for NIL handles and pointers, but also things
  29.         that some feel are not so much under their control such as QuickDraw,
  30.         the Segment Loader, the Edition Manager, Apple Events and so on. 
  31.  
  32.     2.    What kind of performance can a user expect from the application
  33.         when it is running in the minimum memory configuration? Performance
  34.         includes not only speed in handling data, but also things like how
  35.         many documents can be opened, etc. 
  36.  
  37.     3.    What are the typical sizes of scraps that a user might wish to work
  38.         with when launching or switching to your application? If there’s not
  39.         enough memory, the scrap may be lost. This doesn’t make users happy. 
  40.  
  41.     4.    While the above thoughts may make you want to increase your minimum
  42.         requested size, you should also consider what environments actual
  43.         real people will have when trying to use your application.  A lot of
  44.         users with relatively small memory configurations may want to use
  45.         your application. Or, many users might want to use it while several
  46.         other, possibly related/complementary applications are running. If
  47.         that is the case, it would be helpful to have a fairly small minimum
  48.         size. 
  49.  
  50.     So what did we do for Sample 3.0?  Sample can easily run out of memory if
  51.     you open too many documents, but it checks before opening a new one
  52.     to make sure that there's enough memory to proceed. These partitions
  53.     allow you to open a dozen and a half windows or more and still be
  54.     able to watch what's going on in your heap with a debugger or other
  55.     memory utility.  For sample code, that's probably a good goal.
  56.     
  57.     This heap size gives Sample lots of room, even with all the segments
  58.     loaded.                                                                    */
  59.     
  60. #define kMinSize    180                /* application's minimum size (in K) */
  61.  
  62. /*    We made the preferred size bigger than the minimum size by 20K, so that
  63.     there would be even more room for the scrap, windows, etc. */
  64.  
  65. #define kPrefSize    200                /* application's preferred size (in K) */
  66.  
  67. #define    rMenuBar    128                /* application's menu bar */
  68. #define    rAboutAlert    128                /* about Alert */
  69.  
  70. #define rFeaturesNotPresent    1000    /* Alert "some required features are missing" */
  71. #define rNoMemoryForApp        1001    /* Alert "Not enough memory to run" */
  72.  
  73. /* The following constants are used to identify menus and their items. The menu IDs
  74.    have an "m" prefix and the item numbers within each menu have an "i" prefix. */
  75.  
  76. #define    mApple                    128        /* Apple menu */
  77. #define    iAbout                    1
  78.  
  79. #define    mFile                    129        /* FILE menu */
  80. #define    iNew                    1
  81. #define iOpen                    2
  82. #define    iClose                    4
  83. #define iSave                    5
  84. #define iSaveAs                    6
  85. #define iRevert                    7
  86. #define iPageSetup                9
  87. #define iPrint                    10
  88. #define    iQuit                    12
  89.  
  90. #define    mEdit                    130        /* Edit menu */
  91. #define    iUndo                    1
  92. #define    iCut                    3
  93. #define    iCopy                    4
  94. #define    iPaste                    5
  95. #define    iClear                    6
  96. #define iPrefs                    8
  97.  
  98. /*  Other menus are defined in the header files for code that uses them */
  99.  
  100. /*    These are for positioning the Disk Initialization dialogs. */
  101.  
  102. #define kDITop                    0x0050
  103. #define kDILeft                    0x0070
  104.  
  105. /*  kNoEvents is the inverse of "every event" -- it means we don't want any
  106.     events.  We use this with WaitNextEvent to let the toolbox fill in the
  107.     mouse position and tick count without extracting any events from the
  108.     event queue.  */
  109.  
  110. #define kNoEvents 0
  111.  
  112. /*    kMinHeap is the minimum result from the following equation:
  113.         
  114.         ORD(GetApplLimit) - ORD(ApplicZone)
  115.         
  116.     for the application to run. It will insure that enough memory will
  117.     be around for reasonable-sized scraps, FKEYs, etc. to exist with the
  118.     application, and still give the application some 'breathing room'.
  119.     To derive this number, we ran under a MultiFinder partition that was
  120.     our requested minimum size, as given in the 'SIZE' resource. */
  121.      
  122. #define kMinHeap                60 * 1024
  123.     
  124. /*    kMinSpace is the minimum result from PurgeSpace, when called at 
  125.     initialization time, for the application to run. This number acts
  126.     as a double-check to insure that there really is enough memory for the
  127.     application to run, including what has been taken up already by
  128.     pre-loaded resources, the scrap, code, and other sundry memory blocks. */
  129.      
  130. #define kMinSpace                24 * 1024
  131.  
  132. /* kExtremeNeg and kExtremePos are used to set up wide open rectangles and regions. */
  133.  
  134. #define kExtremeNeg                -32768
  135. #define kExtremePos                32767 - 1 /* required to address an old Region bug */
  136.  
  137. /* these #defines are used to set enable/disable flags of a menu */
  138.  
  139. #define AllItems    0b1111111111111111111111111111111    /* 31 flags */
  140. #define NoItems        0b0000000000000000000000000000000
  141. #define MenuItem1    0b0000000000000000000000000000001
  142. #define MenuItem2    0b0000000000000000000000000000010
  143. #define MenuItem3    0b0000000000000000000000000000100
  144. #define MenuItem4    0b0000000000000000000000000001000
  145. #define MenuItem5    0b0000000000000000000000000010000
  146. #define MenuItem6    0b0000000000000000000000000100000
  147. #define MenuItem7    0b0000000000000000000000001000000
  148. #define MenuItem8    0b0000000000000000000000010000000
  149. #define MenuItem9    0b0000000000000000000000100000000
  150. #define MenuItem10    0b0000000000000000000001000000000
  151. #define MenuItem11    0b0000000000000000000010000000000
  152. #define MenuItem12    0b0000000000000000000100000000000
  153.